#!/bin/sh

set -e

CPUS=$(getconf _NPROCESSORS_ONLN)
case "$CPUS" in
  [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) ;;
  *) CPUS=1
esac

if [ -n "${DEB_HOST_ARCH:-}" ]; then
    CROSS="-a$DEB_HOST_ARCH"
else
    CROSS=
fi

echo "Memory on this machine:"
egrep '^(Mem|Swap)' /proc/meminfo || true

set -x
DEB_BUILD_OPTIONS="parallel=$CPUS nohppa nomult nocross" dpkg-buildpackage -d -B --no-sign $CROSS
